Computed Values

Count Distinct Values in a Table Column

Description
This customization shows how to count distinct values in a table column.
Variables
Table Name
Select a database table
Field Name
Select a field in the table
Applies to
Page class
Code
 
/// 
/// This method counts distinct values in a table column.
/// 
public int GetCount() 
{ 
    OrderBy oB = new OrderBy(false,true);
    oB.Add(${${Table Name}ClassName}.${Field Name},BaseClasses.Data.OrderByItem.OrderDir.Asc);
    string [] myarray = ${${Table Name}ClassName}.GetValues(${${Table Name}ClassName}.${Field Name}, new WhereClause(), oB, ${${Table Name}ClassName}.MAX_BATCH_SIZE);
    return myarray.Length;
}
     

Terms of Service Privacy Statement